package com.haltakov.letterjumble.ui.components;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;

import com.haltakov.letterjumble.game.api.Player;

import static com.haltakov.letterjumble.ui.LookAndFeel.*;

public class PlayersInfo extends JPanel {
	private static final int MAX_PLAYERS = 4;
	
	
	PlayerPanel playerPanels[];
	int playerCount;
	
	public PlayersInfo() {
		super(new GridLayout(2, 2, 10, 10));
		
		setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		
		playerPanels = new PlayerPanel[MAX_PLAYERS];
		
		for (int i=0; i<MAX_PLAYERS; ++i) {
			playerPanels[i] = new PlayerPanel();
			add(playerPanels[i]);
		}
	}
	
	public void setPlayer(int id, Player player) {
		playerPanels[id].setPlayer(player);
	}
	
	public void setCurrentPlayer(int id) {
		for (int i=0; i<playerPanels.length; ++i)
			playerPanels[i].setBackground(PANEL_BORDER_COLOR);
		
		playerPanels[id].setBackground(CURRENT_PLAYER_PANEL_COLOR);
	}
	
	public void updatePlayer(int id) {
		playerPanels[id].update();
	}
}
